.TH C2PS 1 "15 May 1997"
.SH NAME
c2ps \- converts a file with C/C++ code to Postscript
.SH SYNOPSIS
.B c2ps
[
.B \-?h124abceikmnruvwx
] [
.BI \-F\  defaultfont
] [
.BI \-C\  commentfont
] [
.BI \-K\  keywordfont
] [
.BI \-N\  lnumberfont
] [
.BI \-P\  preprocfont
] [
.BI \-S\  stringfont
] [
.BI \-T\  typefont
] [
.BI \-U\  functionfont
] [
.BI \-X\  nonlatinfont
] [
.BI \-d\  dim
] [
.BI \-f\  fontsize
] [
.BI \-l\  lines
] [
.BI \-p\  paper
] [
.BI \-o\  outputfile
] [
.BI \-s\  space
] [
.BI \-t\  tabsize
] [
.BI \-_\ \  fun_highlight
] [
.BI \-D PREPROC_VAR\ ...
] [
.BI \-U PREPROC_VAR\ ...
] [
.B file ...
]

.SH DESCRIPTION
Converts the specified file(s) containing C/C++ code to Postscript output
conforming to the Adobe Structuring Conventions.

If no input file is specified then input is accepted from stdin.
Postscript output is directed to stdout unless you specify
an output file.
The actual output page may be out with one, two or four columns.

Supported paper types are A4 and Letter.

Tabs in the input stream are expanded (by default) by blank characters to the
closest modulo 8 position. You can specify your own
constant number of blanks different from 8 for a tab to expand.

A formfeed (^L) character makes the converter move to the next column.

By default, C/C++ constructs are highlighted with following standard fonts
presented on every Postscript printer:

.ta .5i +\w'Preprocessor directives'u+2n
	Preprocessor directives	Courier-BoldOblique

	Comments	Helvetica-Oblique

	Strings	Courier-Oblique

	Keywords	Courier-Bold

	Line numbers	Times-Roman

	Types	Courier-Bold

	Function identificators	Bookman-LightItalic
.fi

The rest is printed with Courier (default font). If highlighting is disabled
only the default font is used to print the read code (but not line numbers).

Comments may be printed dimmed to a configurable degree in a way that allows
reader to concentrate mainly on the source itself referring to comments only
when needed.

c2ps has basic preprocessor capabilities. You may define/undefine
preprocessor variables in the command line.
c2ps will neglect those pieces of code that are cut out by the preprocessor
given a set of mentioned variables.

By default, on each column c2ps draws an alphabetic index of all function id
definitions with locations, scanned from the beginning of the file being printed.
As the number of these id's grows the font used to print the index may get
smaller in order to accommodate all the entries.

Occasionally, function index is drawn upon already printed source code.
To cope with this you can either cancel the index option or use smaller fonts.

All the read symbols with codes 128..255 (0x80..0xff) are printed escaped
so that c2ps output is all clean 7-bit ascii and can be sent
over the Internet without uuencoding.

You can easily print source including fragments in Cyrillic, Hebrew, Arabic etc.
which may be found in string and/or comments if you're printing C/C++ code and
anywhere otherwise. You just need a postscript font with encoding corresponding
to the one that is used in the above fragments. If there's no suitable built-in
font in your PS printer you will have to prepend one to c2ps output.

If the symbols from the both halves of the code table are implemented in your PS
font, you may simply use it to print any constructs that include 8-bit text.
(don't forget to disable ISO Latin 1 font reencoding).
Otherwise, with only upper half symbols (with codes > 127(0x7f)) implemented,
there is an option to set a font to print specifically these symbols leaving
the rest to be printed by either default or newly set fonts.

Also, as much as we know there exists a version of c2ps modified to support
Chinese (Hanja) and Korean (Hangul). An address of the implementor is
on the c2ps web page.

This is a manual page for c2ps ver4.0

.SH OPTIONS

.TP
.B \-? \-h
Print usage message.

.TP
.B \-1
Specify single column per page output - default (portrait).

.TP
.B \-2
Specify two columns per page output (1/2 size, landscape).

.TP
.B \-4
Specifiy four columns per page output (1/4 size, portrait).

.TP
.B \-a
Disable adjusted multiple lines comments printing.

.TP
.B \-b
Disable drawing a box containing alphabetic index of functions
scanned from the beginning of the file.

.TP
.B \-c
Disable C/C++ construct highlighting.

.TP
.B \-e
Disable printing entry/exit function name in the column's header.

.TP
.B \-i
Disable ISO 8859-1 (ISO Latin 1) character encoding.

.TP
.B \-k
Use standard set of keywords rather than extended one.

.TP
.B \-m
When printing a file use the date of printing instead of file's
last modification date.

.TP
.B \-n
Disable line numbering.

.TP
.B \-r
Draw a frame round each column.

.TP
.B \-u
Disable drawing header at the top of each column.

.TP
.B \-v
Print current version.

.TP
.B \-w
Disable wrapping too wide lines onto following lines.
Note, that when wrapping is enabled the maximum number of characters in line printed with any
font is the number of the same point size Courier characters that may appear in single line
without crossing column's border.

.TP
.B \-x
Automatically toggle C/C++ highlight flag for each file according to its extension.
( Applicable extensions include  .c .h .cc .hh .cpp .hpp )

.TP
.BI \-F\  defaultfont
Use 
.I defaultfont 
as default font.

.TP
.BI \-C\  commentfont
 Use 
.I commentfont 
to print comments.

.TP
.BI \-K\  keywordfont
Use 
.I keywordfont 
to print keywords.

.TP
.BI \-N\  lnumberfont
Use 
.I lnumberfont 
to print line numbers.

.TP
.BI \-P\  preprocfont
Use 
.I preprocfont 
to print preprocessor directives.

.TP
.BI \-S\  stringfont
Use 
.I stringfont 
to print strings.

.TP
.BI \-T\  typefont
Use 
.I typefont 
to print types.

.TP
.BI \-U\  functionfont
Use 
.I functionfont 
to print function identificators being defined.

.TP
.BI \-X\  nonlatinfont
Use 
.I nonlatinfont 
to print all symbols with codes > 127(0x7f). ISO Latin 1 encoding is automatically cancelled.

.TP
.BI \-d\  dim
Print comments dimmed with the coefficient
.I dim\.
 ( black: 0.0 <= dim <= 1.0 :white ). Default is 0.75.
So you can actually get rid of the comments in your printout by setting dim coef. to 1.0

.TP
.BI \-f\  pointsize
Use 
.I pointsize 
-scaled fonts ( 10 - default ).

.TP
.BI \-l\  lines
Make converter start a new column after each set of
.I lines
printed lines. You may want to use the resulted at the bottom of the column
white space for notes if the space on the right is not sufficient.

.TP
.BI \-p\  paper
Paper type specification ( A4 - default, Letter ).

.TP
.BI \-s\  points
Leave
.I points 
* 1/72 inch space between lines ( 0.0 - default ).

.TP
.BI \-t\  tabsize
Expand each read tab with blanks to a next modulo
.I tabsize 
position ( 8 - default ).

.TP
.BI \-_\ \  fun_highlight
Specify function id highlighting type ( none, box, underline - default ).

.TP
.BI -D PREPROC_VAR
.TP
.BI -U PREPROC_VAR
You may define or undefine preprocessor variables in a standard
compiler option fashion.

.ta
Below:
 +/-: printed/not printed by c2ps
 column 1: for variable X not mentioned in command line
 column 2: for variable X defined
 column 3: for variable X undefined
.fi

.ta .3i +\w'www'u +\w'www'u +\w'www'u+2n
  	1	2	3
  	+	-	-	#ifdef X
  	+	+	-	  C/C++ code (+ preprocessor directives)
  	+	-	-	#else
  	+	-	+	  C/C++ code (+ preprocessor directives)
  	+	-	-	#endif
.fi

Similarly for #ifndef, just switch columns 2 and 3.


.SH EXAMPLES

.ta
Multiple files 
   c2ps *.c *.h | lpr

Ordinary text
   c2ps note.txt -c -n -u > note.ps

ISO Latin 1 font reencoding by default
   c2ps -2 -c -n -F Times-Roman german.txt > german.ps

A different look
   c2ps -F Times-Roman -C Palatino-BoldItalic -K Times-Bold
        -N Helvetica -P Helvetica-Bold -S Times-Italic
        -T Times-BoldItalic -_ box -w sample.c > sample.ps 

An option set looking better on low resolution printers
   c2ps -d 0 -C Palatino-Italic main.cc > main.ps

Partial preprocessing, selective printing
   c2ps -DDEBUG -DSUN_SPECIFIC -UPRINT *.cc | lpr

Temporarily commented out code (still looks like a part of the code
but a little bit dimmed)
   c2ps -C Courier -d 0.5 temp.c -o temp.ps

Getting rid of comments
   c2ps -_ box -d 1 main.cc | lpr

Printing 8-bit text (e.g. Cyrillic, koi-8 encoding)
   c2ps -i -C Antique-Italic -S Antique koi8.cc > tmp
   cat Antique-Italic.pfa Antique.pfa tmp | lpr

   c2ps -i -c -n -F Antique koi8.cc > tmp
   cat Antique.pfa tmp | lpr

   c2ps -X Cyrillic-Italic-koi8 koi8.cc > tmp
   cat Cyrillic-Italic-koi8.ps tmp | lpr
.fi

.SH BUGS
c2ps is generally quite stable. Howerver, if you encounter any problem
using it, please, send a report to: 
.ta

   c2ps@geocities.com

.fi
Last version of c2ps is located at
.ta

   http://www.geocities.com/SiliconValley/Park/2055/

.fi

.SH SEE ALSO
enscript, vgrind, troff, pprint, a2ps

.SH ACKNOWLEDGEMENTS
We would like to thank Prof. Daniel Berry of the Technion who has supervised
this project at its beginning for numerous most useful recommendations.
Also, we are very thankful for many suggestions, proposals and of course
bug reports that have been received.

.SH AUTHORS
Dmitri Shtilman
.br
Dmitri Makarov
